package com.liujun.spring4.demo.aop.aop.jdkproxy;

import java.lang.reflect.Proxy;

/**
 * @author liujun
 * @version 0.0.1
 * @date 2018/09/19
 */
public class JdkProxyMain {

  public static void main(String[] args) {
    ForumService base = new ForumServiceImpl();

    PerformanceHandler handler = new PerformanceHandler(base);

    try {
      ForumService baseProxy =
          (ForumService)
              Proxy.newProxyInstance(
                  base.getClass().getClassLoader(), base.getClass().getInterfaces(), handler);

      baseProxy.removeTopic(10);

      System.out.println("---------------");
      baseProxy.removeForm(20);
    } catch (IllegalArgumentException e) {
      e.printStackTrace();
    }
  }
}
